#include "paintwindow.h"
#include "ui_paintwindow.h"

PaintWindow::PaintWindow(QWidget *parent) :QWidget(parent),ui(new Ui::PaintWindow)
{
    ui->setupUi(this);
    resize(1000,1000);
}

PaintWindow::~PaintWindow()
{
    delete ui;
}
void PaintWindow::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QPen pen;
    pen.setColor(QColor("#005179")); //品红
    pen.setWidth(6);

    painter.setPen(pen);
    painter.setBrush(QBrush(Qt::blue));
    //平移坐标
    painter.translate(500,500);
    //抗锯齿
    painter.setRenderHint(QPainter::Antialiasing);

    painter.drawEllipse(QPoint(0,0),400,400);

    pen.setColor(Qt::green);
    painter.setPen(pen);
    painter.rotate(45);
    painter.drawLine(QPoint(0,400),QPoint(0,360));

    QFont font;
    font.setPointSize(16);
    font.setBold(true);
    painter.setFont(font);
    int numtodraw = 10;
    QString numbertext = QString :: number(numtodraw);
    //-50,300,100,30  矩形框大小
    painter.drawText(-50,300,100,30,Qt::AlignCenter,numbertext);

#if 1
    for(int i = 1;i<31;i++)
    {
        if(i%5 != 0)
        {
            pen.setColor(Qt::yellow);
            painter.setPen(pen);
            painter.rotate(9);
            painter.drawLine(QPoint(0,400),QPoint(0,380));
        }else
        {
            pen.setColor(Qt::green);
            painter.setPen(pen);
            painter.rotate(9);
            painter.drawLine(QPoint(0,400),QPoint(0,360));   
        }
    }
#endif
}
